<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>列表元素单击事件的响应</title>
</head>
<body>
<div id="app">
    <ul>
        <li v-for="(item, key) in arr" v-liclicked="item">{{ item }}</li>
    </ul>
</div>

<script type="module">
    import {createApp, reactive} from "../../../../js/vue.esm-browser.js";

    let app = createApp(
        {
            setup() {

                let arr = reactive([1, 2, 3, 4, 5, 6, 7, 8, 9])
                return {
                    arr
                }
            }
        }
    )

    app.directive(
        "liclicked",
        {
            beforeMount(el, binding){
                // el.bind = binding
                // console.log(el);
                el.onclick = function () {
                    console.log(binding.value);
                }
            },

            updated(el, binding){

            }
        }
    )

    app.mount("#app")
</script>
</body>
</html>